package com.tddx.activiti.business.core.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.tddx.activiti.utils.StringUtils;

/**
 * 实体类 
 * @Auth yanweizhao 
*/
@Entity
@Table(name="USER_TAB_COLS", schema="SYS")
public class UserTabColsEntity implements Serializable{
	
	/**
	 * 序列化版本号
	 */
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private ColId pk;
	
	@Column(name="DATA_TYPE")
	private String dataType;
	
	@Column(name="DATA_LENGTH")
	private String dataLength;
	
	@Column(name="NULLABLE")
	private String nullAble;
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name="TABLE_NAME", referencedColumnName="TABLE_NAME", insertable=false, updatable=false),
		@JoinColumn(name="COLUMN_NAME", referencedColumnName="COLUMN_NAME", insertable=false, updatable=false)
	})
	private UserColCommentsEntity colComment;
	
	@Transient
	private String colPro;//字段变属性
	
	@Transient
	private String colGetPro;//字段变GET方法名
	
	@Transient
	private String colSetPro;//字段变SET方法名
	
	public ColId getPk() {
		return pk;
	}

	public void setPk(ColId pk) {
		this.pk = pk;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public String getDataLength() {
		return dataLength;
	}

	public void setDataLength(String dataLength) {
		this.dataLength = dataLength;
	}

	public String getNullAble() {
		return nullAble;
	}

	public void setNullAble(String nullAble) {
		this.nullAble = nullAble;
	}

	public UserColCommentsEntity getColComment() {
		if(colComment==null){
			return new UserColCommentsEntity();
		}
		return colComment;
	}

	public void setColComment(UserColCommentsEntity colComment) {
		this.colComment = colComment;
	}

	public String getColPro() {
		String pkColname = pk.getColumnName();
		this.colPro = StringUtils.lowerFirst(StringUtils.lowerCase(pkColname), "_", "\\$");
		return colPro;
	}

	public void setColPro(String colPro) {
		this.colPro = colPro;
	}

	public String getColGetPro() {
		String pkColname = pk.getColumnName();
		this.colGetPro = "get" + StringUtils.capitalizeBySymbol(StringUtils.lowerCase(pkColname), "_", "\\$");
		return colGetPro;
	}

	public void setColGetPro(String colGetPro) {
		this.colGetPro = colGetPro;
	}

	public String getColSetPro() {
		String pkColname = pk.getColumnName();
		this.colSetPro = "set" + StringUtils.capitalizeBySymbol(StringUtils.lowerCase(pkColname), "_", "\\$");
		return colSetPro;
	}

	public void setColSetPro(String colSetPro) {
		this.colSetPro = colSetPro;
	}
	
}